public class MissingNumber {
    public int missingNumber(int[] nums) {
        int n = nums.length;

        int ret = 0;
        for(int i = 0; i <= n; i++) {
            ret ^= i;
            if(i < n) {
                ret ^= nums[i];
            }
        }

        return ret;
    }
}
